package example.file;

import java.io.*;

/**
 * Created by lenovo on 2016/11/4 0004.
 * fileWriter向文件中追加数据
 */
public class AppendData {
    public static void main(String[] args) throws Exception {
        try {
            BufferedWriter bw = new BufferedWriter(new FileWriter("filename"));
            bw.write("aString1\n");
            bw.close();
            bw = new BufferedWriter(new FileWriter("filename", true));
            bw.write("aString2");
            bw.close();
            BufferedReader br = new BufferedReader(new FileReader("filename"));
            String str;
            while ((str = br.readLine()) != null) {
                System.out.println(str);
            }
            br.close();
        } catch (IOException e) {
            System.out.println("exception occoured" + e);
        }
    }
}
